<?php
putenv("DISPLAY=:1");
putenv("XAUTHORITY=/var/www/.Xauthority");

ini_set('display_errors',1);
error_reporting(E_ALL);

include_once 'Bot.php';
include_once 'RedmineApi.php';
include_once 'Api.php';

$dbus = new Dbus(Dbus::BUS_SESSION, true);

$n = $dbus->createProxy('com.Skype.API', '/com/Skype', 'com.Skype.API');
$n->Invoke('NAME BOT');
$n->Invoke('PROTOCOL 8');

$dbus->registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'phpSkype'); //Регистрируем просмотр уведомлений скайпа
$count = 0;

while(true) {
    $s = $dbus->waitLoop(1);
}

class phpSkype {

    public static function notify($notify) {
        var_dump('step 2');
        var_dump($notify);
        file_put_contents('logs/log_skype' . date('d-m-Y'), date('H-i-s') . ' - ' . serialize($notify) . "\n", FILE_APPEND);

        if (preg_match('/RECEIVED/', $notify)) {
            var_dump('step 3');
            $messageId = explode(' ', $notify);
            Bot::getInstance()->getDetails($messageId[1]);
        }
    }
}